#include "UtilCommon.h"

initSing(FileLogHandler);

bool FileLogHandler::AddLogFile(LogType type, const char* filename)
{
	if(m_filelogs[type])
		return false;
	FileInfo* inf = new FileInfo;
	inf->fileptr = fopen(filename, "a");
	m_filelogs[type] = inf;
	return true;
}

void FileLogHandler::WriteToLog(LogType type, const char* title, const char* text, ...)
{
	FileInfo* inf = m_filelogs[type];
	if(!inf)
		return;
	if(!inf->fileptr)
		return;
	inf->filemutex.Acquire();
	/*va_list ap;
	va_start(ap, text);
	vfprintf(inf->fileptr, text, ap);
	va_end(ap);*/
	fprintf(inf->fileptr, text);
	fflush(inf->fileptr);
	inf->filemutex.Release();
}